﻿#pragma once
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
#include <highgui.h>
#include <opencv2/opencv.hpp>
#include "include/Widget/Setting.h"
#include"memory"

#include<QMap>

const int DEV_ERR_IRI_SCAM_NOTOPEN = -1;

const int DEV_ERR_IRI_CAMERA_NOT_INIT = -2;



enum CameraProperty {										//enum 枚举数据类型
	 Exposure=cv::CAP_PROP_EXPOSURE,
	 Brightness=cv::CAP_PROP_BRIGHTNESS,						//10
	 Contrast=cv::CAP_PROP_CONTRAST,							//11
	 Saturation=cv::CAP_PROP_SATURATION,						//12
	 Hue=cv::CAP_PROP_HUE,										//13
	 Gamma=cv::CAP_PROP_GAMMA,									//22
	 Width=cv::CAP_PROP_FRAME_WIDTH,							//3
	 Height=cv::CAP_PROP_FRAME_HEIGHT,							//4
	 //ISOSpeed=CV_CAP_PROP_ISO_SPEED								//30
};

class BinocularCamera {

public:

	struct CameraInfo {
		int id;
		int errorCode;
		QString errorMsg;
		cv::VideoCapture* vc = nullptr;			//视频捕捉器
		bool isCameraConnected();
		~CameraInfo();
	};

	BinocularCamera(USBPort id);				//输入USB端口号

	~BinocularCamera();

	bool read(cv::Mat& outMat);					//读取信息

	int isConnect();

	void close();

	void open();

	void setParam(int type,double value);
	double getParam(int type);

	void reOpen();

	QString getErrorMsg()const {
		return _errorMsg;
	}

	int getErrorCode()const {
		return _errorCode;
	}

private:
	QString _errorMsg;
	int _errorCode;
	CameraID _port;
	bool _isCameraInitialize = false;
	std::shared_ptr<CameraInfo> _cam;		//设置智能指针,必须要提供指针可以指向的类型；_cam -> CameraInfo

};
